package com.aaa.dao.impl;

import com.aaa.dao.RoleDao;
import com.aaa.util.BaseDao;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author ：Teacher陈
 * @date ：Created in 2020/9/24 9:06
 * @description：角色dao实现类
 * @modified By：
 * @version: 1.0
 */
public class RoleDaoImpl extends BaseDao implements RoleDao {
    @Override
    public List<Map<String, Object>> findAllRole() {
        String sql="select * from tbl_role";
        return executeQuery(sql);
    }

    /**
     * @create by: Teacher陈
     * @description: 保存角色
     * @create time: 2020/9/26 10:02
     * @return
     */
    @Override
    public Integer saveRole(Map<String, String> map) {
        String sql="insert into tbl_role(role_name,role_key,role_sort,status,create_by,create_time,remark) values (?,?,?,?,?,?)";
        Integer insert = executeUpdateRetKey(sql,map.get("role_name"),map.get("role_key"),map.get("role_sort"),map.get("status"),"admin",new Date(),map.get("remark"));
        return insert;
    }

    @Override
    public boolean saveRoleMenu(Integer roleId,Integer menuId) {
        String sql="insert into tbl_role_menu(role_id,menu_id) values (?,?)";
        boolean insert = executeUpdate(sql,roleId,menuId);
        return insert;
    }
}
